package com.lvmama.pangolin.proxyip.inter.impl;



import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import com.lvmama.pangolin.entity.IP;
import com.lvmama.pangolin.proxyip.inter.ProxyIPProcesser;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author wuchuantong
 * @version V1.0
 * @Title: todo
 * @Package com.nuctony.vote.inter.impl
 * @Description: todo
 * @date 2017/1/4 11:15
 */
public class MiMiIPProcesser implements ProxyIPProcesser {
    public List<IP> parseDoc(Document doc) {
        List<Element> trEleList = doc.select("#middle_wrapper table.list").select("tbody tr");
        trEleList.remove(0);
        List<IP> proxyIPVOs = new ArrayList<IP>();
        Date curDate = new Date();
        for (Element element : trEleList) {
            List<Element> tdEles = element.select("td");
            IP proxyIPVO = new IP();
            proxyIPVO.setIp(tdEles.get(0).text());
            proxyIPVO.setIp_port(tdEles.get(1).text());
            proxyIPVO.setAnonymity(tdEles.get(3).text());
            proxyIPVO.setIp_addr(tdEles.get(2).text());
            proxyIPVO.setIp_type(tdEles.get(4).text());
//            proxyIPVO.setVerifyTime(tdEles.get(6).text());
            proxyIPVO.setInsert_time(curDate);
            proxyIPVOs.add(proxyIPVO);
        }
        return proxyIPVOs;
    }
}
